home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cbibcode.arc
/
STLPLT.C
< prev
next >
Wrap
Text File
|
1991-08-05
|
2KB
|
59 lines
#include <stdio.h>
#include <graphics.h>
/* Define new color map using defined constants from
* graphics.h. Notice that we have swapped red with blue
* and cyan with black. So the background will become
* cyan now.
*/
struct palettetype newcolormap[] =
{16,
EGA_CYAN, EGA_RED, EGA_GREEN, EGA_BLACK, EGA_BLUE,
EGA_MAGENTA, EGA_BROWN, EGA_LIGHTGRAY,
EGA_DARKGRAY, EGA_LIGHTBLUE, EGA_LIGHTGREEN,
EGA_LIGHTCYAN, EGA_LIGHTRED, EGA_LIGHTMAGENTA,
EGA_YELLOW, EGA_WHITE};
main()
{
int i;
short color=0, x1=0, y1=60, x2=100, y2=70;
int graphdriver = DETECT;
int graphmode;
/* Detect and initialize graphics system */
initgraph(&graphdriver, &graphmode, "c:\\turboc");
if (graphdriver != EGA && graphdriver != VGA)
{
/* Error setting mode */
printf("Not EGA/VGA hardware\n");
exit(0);
}
/* Display rectangles filled with colors from current
* palette
*/
outtextxy(10,10, "Remapping the color palette using setallpalette");
/* Draw the filled rectangles */
for (i=1; i<=8; i++)
{
color = 2*i-1;
setfillstyle(SOLID_FILL, color);
bar(x1, y1, x2, y2);
y1 += 20;
y2 += 20;
}
/* Now remap entire palette--swap red with blue, cyan
* with black
*/
setcolor(EGA_RED);
outtextxy(10, 30, "Hit any key to remap the entire palette:");
getch();
/* Display changes immediately */
setallpalette(newcolormap);
/* Restore mode back to where we originally started */
/* Give user a chance to see the result */
outtextxy(10, getmaxy()-50, "Hit any key to exit:");
getch();
closegraph();
}